<?php
namespace app\live\controller\sys_admin;
use app\live\model\LiveRoomModel;
use tencent\IMGroup;
use think\Db;
use app\AdminController;
use app\member\model\UsersModel;
use app\shop\model\OrderGoodsModel;
/**
 * 微信设置
 * Class Index
 * @package app\store\controller
 */
class LiveGroup extends AdminController
{
    protected $imGroup;
	/*------------------------------------------------------ */
	//-- 优先执行
	/*------------------------------------------------------ */
	public function initialize(){
        parent::initialize();

        $SDKAppID = settings('tx_SDKAppID');
        $secretKey = settings('tx_secretKey');
        $this->imGroup = new IMGroup($SDKAppID, $secretKey);
    }

    /*------------------------------------------------------ */
    //--首页
    /*------------------------------------------------------ */
    public function index()
    {
        $groupList = $this->imGroup->getGroupList();
        $this->assign('groupList', $groupList);
        return $this->fetch('index');
    }

    public function showInfo()
    {
        $id = input('id');
        $groupInfo = $this->imGroup->getGroupInfo($id);

        if (!is_array($groupInfo)) return $this->error('没有找到相关群组数据.');

        $this->assign('groupInfo',$groupInfo[0]);
        return $this->fetch('show_info');
    }

    public function del(){
        $id = input('id');

        $res = $this->imGroup->destroyGroup($id);

        if ($res === true){
            $this->success('解散成功');
        }

        return $this->error($res);
    }
}
